package com.tqy.docms.service.impl;

import com.tqy.docms.dao.LsjcMapper;
import com.tqy.docms.entity.Lsjc;
import com.tqy.docms.service.LsjcService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

/**
 * @title: LsjcServiceImpl
 * @projectName: tqygw
 * @description: 历史进程 服务处
 * @author: yuzf
 * @date: 2019/6/27 15:04
 */
@Service
public class LsjcServiceImpl  implements LsjcService {

    private static final Logger LOG = LoggerFactory.getLogger(LsjcServiceImpl.class);

    @Autowired
    LsjcMapper lsjcMapper;

    @Override
    public int addLsjc(Lsjc lsjc) {
        UUID uuid = UUID.randomUUID();
        lsjc.setNm(uuid.toString().replace("-",""));
        int result = lsjcMapper.addLsjc(lsjc);

        if(result == 1) {
            LOG.info("插入一条数据至TQY_LSJC");
        }else{
            LOG.error("插入数据至TQY_LSJC失败");
        }
        return result;
    }

    @Override
    public int delLsjc(String nm) {
        int result = lsjcMapper.delLsjc(nm);
        if(result>0) {
            LOG.info("成功删除TQY_LSJC表中"+ result +"条数据");
        }else {
            LOG.error("删除TQY_LSJC表中数据失败");
        }
        return result;
    }

    @Override
    public int editLsjc(Lsjc lsjc) {
        int result = lsjcMapper.editLsjc(lsjc);
        if(result>0) {
            LOG.info("成功修改TQY_LSJC表中"+ result +"条数据");
        }else {
            LOG.error("修改TQY_LSJC表中数据失败");
        }
        return result;
    }

    @Override
    public List<Lsjc> getallLsjc() {
        List<Lsjc> lsjcs = lsjcMapper.getallLsjc();

        return lsjcs;
    }

    @Override
    public Lsjc getoneLsjc(String nm) {
        Lsjc lsjc = lsjcMapper.getoneLsjc(nm);
        return lsjc;
    }


    @Override
    public List<Lsjc> selectLsjc(Lsjc lsjc) {
        List<Lsjc> lsjcs = lsjcMapper.getLsjc(lsjc);
        return lsjcs;
    }


}
